package com.nobug.controller.system;

import com.nobug.bean.BaseListData;
import com.nobug.bean.BaseRespVo;
import com.nobug.bean.system.Storage;
import com.nobug.service.system.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/")
public class StorageController {

    @Autowired
    StorageService storageService;

    @RequestMapping("storage/list")
    public BaseRespVo storageList(Integer page, Integer limit, String key, String name, String sort, String order){
        BaseListData data = storageService.queryStorageList(page,limit,key,name,sort,order);
        return BaseRespVo.ok(data);
    }

    @RequestMapping("storage/update")
    public BaseRespVo storageUpdate(@RequestBody Storage storage){
        Storage data = storageService.updateStorage(storage);
        return BaseRespVo.ok(data);
    }

    @RequestMapping("storage/delete")
    public BaseRespVo storageDelete(@RequestBody Storage storage){
        storageService.deleteStorage(storage);
        return BaseRespVo.ok();
    }

}
